﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using Booking_Hotel.BLL;
using Booking_Hotel.DBML;
using System.Web.Security;
using Booking_Hotel.DAL;

namespace Booking_Hotel
{
    public partial class Supplier_Active : System.Web.UI.Page
    {
        Supplier supplierF = new Supplier();
        ThanhBHotelDataContext TBK = new ThanhBHotelDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            supplierF = new Supplier();            // Set mới lại.
            supplierF.UserName = DropDownList1.SelectedValue.ToString();
            DateTime dtime = DateTime.Parse(txt_Date.Text);
            supplierF.NgayActive = dtime;
            supplierF.SupplierLevel = byte.Parse(txt_SupplierLever.Text.Trim());

            if (CB_Active.Checked == true)
            {
                supplierF.Active = true;
            }
            else
            {
                supplierF.Active = false;
            }

            SupplierDAO sp = new SupplierDAO();
            sp.SupplierActive(supplierF);

            var supplierSource = from sl in TBK.Suppliers
                                 where sl.UserName == DropDownList1.SelectedValue.ToString()
                                 select new
                                 {
                                    supplierid =sl.SupplierID,
                                     username = sl.UserName,
                                     ngayactive = sl.NgayActive,
                                     Supplierlevel = sl.SupplierLevel,
                                     active = sl.Active
                                 };
            
          
            gv_Supplier.DataSource = supplierSource;
            gv_Supplier.DataBind();
        }
    }
}